package top.littleze.aiattendance.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import top.littleze.aiattendance.service.impl.UserServiceImpl;
import top.littleze.aiattendance.utils.page.Reply;

/**
 * @Author ZhaoGengze
 * @Date 2021/7/3 12:12
 */

@RestController
@ResponseBody
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserServiceImpl userServiceImpl;

    /**
     * 登录
     * @param userId
     * @param password
     */
    @RequestMapping("/login")
    public Reply login(@RequestParam("username") String userId, @RequestParam("password") String password) {
        // 验证用户名、密码不为空
        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(password)) {
            return Reply.failuer(1, "用户名或密码不能为空");
        }
        // 登录验证
        return userServiceImpl.login(userId, password);
    }

}
